﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkFlowOrder.aspx.cs" Inherits="ZX.WebApp.Crm.BasePages.WorkFlowOrder" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ Register Assembly="ZX.Web.UI.Controls" Namespace="ZX.Web.UI.Controls.UserControl"
    TagPrefix="cc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //        var _fn;
        //        var Save = function () {
        //            debugger;
        //            if (typeof (_fn) == "function") {
        //                debugger;
        //                _fn();
        //            }
        //        };
        var names = "";
        var ids = "";
        var rank = "";
        var i = "";
        function ChooseInfo() {   //todo zhuyun
            debugger;
            parent._fn("", "");
            names = names.substring(0, names.length - 1);
            for (i = 0; i < document.getElementById('lstBoxResult').length; i++) {
                names += document.getElementById('lstBoxResult')[i].text.split('(')[0] + ",";
                ids += document.getElementById('lstBoxResult')[i].value + ",";
            }
            var boxname = document.getElementById('lstBoxResult').outerText;
            rank = "";
            parent._fn(ids, names);
            //       }
        }
        $(function () {
            //移到右边
            $('#add').click(function () {
                //获取选中的选项，删除并追加给对方
                $('#lstBoxSubject option:selected').appendTo('#lstBoxResult');
            });
            //移到左边
            $('#remove').click(function () {
                $('#lstBoxResult option:selected').appendTo('#lstBoxSubject');
            });
            //全部移到右边
            $('#add_all').click(function () {
                //获取全部的选项,删除并追加给对方
                $('#lstBoxSubject option').appendTo('#lstBoxResult');
            });
            //全部移到左边
            $('#remove_all').click(function () {
                $('#lstBoxResult option').appendTo('#lstBoxSubject');
            });
            //双击选项
            $('#lstBoxSubject').dblclick(function () { //绑定双击事件
                //获取全部的选项,删除并追加给对方
                $("option:selected", this).appendTo('#lstBoxResult'); //追加给对方
            });
            //双击选项
            $('#lstBoxResult').dblclick(function () {
                $("option:selected", this).appendTo('#lstBoxSubject');
            });

        });
        //查找按钮事件
        function SearchName() {
            var vName = $("#txtSearch").val();
            if (vName != "") {
                document.getElementById('lstBoxSubject').length = 0;
                var url = "../../Extend/AjaxData/CustomOperating.aspx?action=check&entity=V_DatEmployeeForName&id=" + encodeURI(vName);
                YAHOO.util.Connect.asyncRequest('POST', url, {
                    success: function (res) {
                        var inventory;
                        try {
                            inventory = res.responseText;
                            var Employee = [];
                            var obj = eval(inventory);
                            for (var i = 0; i < obj.length; i++) {
                                $('#lstBoxSubject').append('<option value=' + obj[i].LoginName + '>' + obj[i].Name + '(' + obj[i].DeptName + ":" + obj[i].EmpCode + ')</option>');
                            }
                        }
                        catch (e) {
                        }
                        finally {
                        }
                    },
                    failure: function (error) {
                        alert("数据错误：" + error.statusText);
                    }
                }, null);
            } else {
                $("#txtSearch").focus();
            }
        }
        function ChangeDept() {
            var deptId = $('#SelectForDept').val();
            if (deptId == "" || deptId == null) {
                alert("请选择部门!");
            } else {
                var deptIndex = $("#SelectForDept").get(0).selectedIndex;
                document.getElementById('lstBoxSubject').length = 0;
                if (deptIndex == 0) {
                    return;
                } else {
                    debugger
                    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=check&entity=V_DatEmployeeForUser&id=" + deptId;
                    YAHOO.util.Connect.asyncRequest('POST', url, {
                        success: function (res) {
                            var inventory;
                            try {
                                inventory = res.responseText;
                                var Employee = [];
                                var obj = eval(inventory);
                                for (var i = 0; i < obj.length; i++) {
                                    $('#lstBoxSubject').append('<option value=' + obj[i].LoginName + '>' + obj[i].Name + '(' + obj[i].DeptName + ":" + obj[i].EmpCode + ')</option>');
                                }
                            }
                            catch (e) {
                            }
                            finally {
                            }
                        },
                        failure: function (error) {
                            alert("数据错误：" + error.statusText);
                        }
                    }, null);
                }
            }
        }

        function changepos(obj, index) {     ///上移下移 todo zhuyun
            if (index == -1) {
                if (obj.selectedIndex > 0) {
                    obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex - 1))
                }
            }
            else if (index == 1) {
                if (obj.selectedIndex < obj.options.length - 1) {
                    obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex + 1))
                }
            }
        }

    </script>
</head>

<body>
<form id="form1" runat="server">
    <div>
        <table style="width: 100%; height: 100%;">
            <tr valign="bottom">
                <td style="text-align: right;">
                    所属部门
                </td>
                <td colspan="3">
                    <cc1:DeptList ID="DeptList1" runat="server"></cc1:DeptList>
                    <%--<asp:DropDownList ID="drpDept" runat="server" Width="155px" AppendDataBoundItems="true"
                        AutoPostBack="True" OnSelectedIndexChanged="drpDept_SelectedIndexChanged">
                        <asp:ListItem Value="00">--选择部门过滤--</asp:ListItem>
                    </asp:DropDownList>--%>
                </td>
            </tr>
            <tr valign="bottom">
                <td>&nbsp;</td>
                <td colspan="3">
                    <input type="text" id="txtSearch" name="txtSearch" style="width: 140px;" />
                    <input type="button" id="btnSearch" name="btnSearch" onclick="SearchName()" value="查找"
                        class="btnCheck" style="width: 50px; height: 20px;" />
                </td>
            </tr>
            <tr><td>&nbsp;&nbsp;&nbsp;</td></tr>
            <tr>
                <td style="text-align: right;">
                    人员列表
                </td>
                <td>
                    <asp:ListBox ID="lstBoxSubject" runat="server" Height="220px" Width="155px"></asp:ListBox>
                </td>
                <td>
                    <button id="add" type="button" style="width: 55px;" class="btnCheck">
                        →</button><br />
                    <br />
<%--                    <button id="add_all" type="button" style="width: 55px;" class="btnCheck">
                        >></button><br />--%>
                    <button id="Button1" type="button" style="width: 55px;" class="btnCheck" onclick="changepos(lstBoxResult,-1)"  >
                        ↑</button><br /><br />
                    <button id="Button2" type="button" style="width: 55px;" class="btnCheck" onclick="changepos(lstBoxResult,1)"  >
                        ↓</button><br />
                    <br />
                    <button id="remove" type="button" style="width: 55px;" class="btnCheck">
                        ←</button><br />
                    <br />
<%--                    <button id="remove_all" type="button" style="width: 55px;" class="btnCheck">
                        <<</button>--%>
                </td>
                <td>&nbsp;&nbsp;&nbsp;</td>
                <td>
                    <asp:ListBox ID="lstBoxResult" runat="server" Height="220px" Width="155px"></asp:ListBox>
                </td>
                <td>
<%--                <select style="WIDTH:100%" multiple name="list2" size="12" ondblclick="moveOption(document.myform.list2, document.myform.list1)">
                </select>--%>
                </td>
                <td>

                </td>
            </tr>
            <asp:HiddenField ID="hdnUid" runat="server" />
            <asp:HiddenField ID="hiddenId" runat="server" />
            <asp:HiddenField ID="hiddenDId" runat="server" />
            <asp:HiddenField ID="hiddenType" runat="server" />
            <asp:HiddenField ID="hiddenEntity" runat="server" />
        </table>
    </div>
    </form>
       <form id="form2" style="display: none" action="../../Extend/AjaxData/CustomOperating.aspx">
    <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    </form>
</body>
</html>